package com.xmkj.bearuser.my.adapter;

import android.content.Context;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.common.Entity.ShareOrderEntity;
import com.common.bean.FriendCicleBean;
import com.common.widget.recyclerview.refresh.adapter.CommonAdapter;
import com.common.widget.recyclerview.refresh.adapter.ViewHolder;
import com.xmkj.bearuser.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Create by leo
 * 创建日期：2018/5/11
 * 描述：
 */

public class ShareOrderAdapter extends CommonAdapter<ShareOrderEntity.ListsEntity> {
    public ShareOrderAdapter(Context context, List<ShareOrderEntity.ListsEntity> data) {
        super(context, data);
    }

    @Override
    protected void convert(ViewHolder holder, ShareOrderEntity.ListsEntity item, int position) {
        holder.setText(R.id.tv_name, item.nickname);
        holder.setText(R.id.tv_date, item.show_time);
        holder.setText(R.id.tv_info, item.goodname);
        holder.setText(R.id.tv_content, item.content);
        holder.setText(R.id.tv_qihao, "期号：" + item.fvid);

        //大图处理
        RecyclerView rvPic = holder.getView(R.id.rv_pics);
        GridLayoutManager layoutManager = new GridLayoutManager(mContext, 3);
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        rvPic.setLayoutManager(layoutManager);
        List<FriendCicleBean.ListBean.PictureBean> datas = new ArrayList<>();
        if (item.imgsurl.size() > 0) {
            for (int i = 0; i < item.imgsurl.size(); i++) {
                FriendCicleBean.ListBean.PictureBean bean = new FriendCicleBean.ListBean.PictureBean();
                bean.pic = item.imgsurl.get(i);
                datas.add(bean);
            }

            rvPic.setAdapter(new SharePicAdapter(datas, mContext));
        }
    }

    @Override
    protected int getItemViewLayoutId(int position, ShareOrderEntity.ListsEntity item) {
        return R.layout.item_share_order;
    }
}
